//
// Created by mi on 2024/2/3.
//
#include <iostream>
#include <vector>
#include <map>
#include <deque>
#include <set>
#include <list>

using namespace std;
// array  vector deque list forward_list ,heap ,queue ,priority queue ,set ,map  ,mult_map ,mult_set ,unorder_map
int main() {
    /*
    //vector
    std::vector<int> v = {1, 2, 3, 4, 5};
    for (auto it = v.begin(); it != v.end();) {
       // std::cout << "vector value: " << *it << std::endl;
        if (*it == 2) {
            it = v.erase(it);
        } else {
            it++;
        }
    }
    for (auto item : v) {
        std::cout << "vector value: " << item << std::endl;
    }
    // deque
    std::deque<int> d = {1, 2, 3, 4, 5};
    for (auto it = d.begin(); it != d.end();) {
        //std::cout << "vector value: " << *it << std::endl;
        if (*it == 2) {
            it = d.erase(it);
        } else {
            it++;
        }
    }

    // set
    std::set<int> s ={0,1,2,3,4,5};
    for (auto it = s.begin(); it != s.end();) {
        std::cout << "set value: " << *it << std::endl;
        if (*it == 2) {
            it = s.erase(it);
        } else {
            it++;
        }
        std::cout << "set size: " << s.size() << std::endl;
    }

    // map
    std::map<int,int> m ={{0,1},{1,2},{2,4}};
    for (auto it = m.begin(); it != m.end();) {
        std::cout << "map value: " << it->first << std::endl;
        if (it->first == 1) {
            it = m.erase(it);
        } else {
            it++;
        }
        std::cout << "map size: " << m.size() << std::endl;
    }
    */
    // list
    std::list<int> l ={0,1,2,3,4,5};
    for (auto it = l.begin(); it != l.end();) {
        std::cout << "list value: " << *it << std::endl;
        if (*it == 2) {
            it = l.erase(it);
        } else {
            it++;
        }
        std::cout << "list size: " <<l.size() << std::endl;
    }

    std::vector<int> v = {1, 2, 3, 4, 5};
    for (auto it = v.begin(); it != v.end();) {
        // std::cout << "vector value: " << *it << std::endl;
        if (*it == 2) {
            it = v.erase(it);
        } else {
            it++;
        }
    }
    v.emplace_back(3);

    return 0;
}
